
import fetchUtil
import fileUtil
import dbUtil
import traceback

ak = 'tRr4qk9CM853usbdtIUsU6y63DCgzjte'

def start():
    timeoutRequesetData = fileUtil.timeoutRequest().load()
    for data in timeoutRequesetData:
        try:
           # print(data)
            reponseData = fetchUtil.getDataByExtent(data['queryType'],data['page_num'], ak, data['extent'], False)
            #print(reponseData)
            dbUtil.batchSaveToDb(reponseData['results'])
        except BaseException:
            #traceback.print_exc()
            print(data)
            #pass
    
def tt():
    reponseData = fetchUtil.getDataByExtent('房地产','9', ak, [28.112208,112.91049784020049,28.295197,112.91236340394892], False)
    dbUtil.batchSaveToDb(reponseData['results'])

if __name__ == "__main__":
    #start()
    tt()